<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:t="http://myfaces.apache.org/tomahawk">

<f:view>
	<f:loadBundle var="messages" basename="messages" />

	<head>
	<title>#{messages['noticiaForm.title']}</title>
	<style type="text/css">
.jscalendar-DB-div-style {
	position: absolute;
	margin-top: -69px;
	margin-left: -408px;
}
</style>
	</head>

	<h:messages errorClass="error" layout="table" style="width: 100%" />

	<h:form id="noticiaForm">
		<h:inputHidden value="#{noticiaForm.noticia.id}">
			<f:convertNumber />
		</h:inputHidden>
		<h:panelGrid columns="3" styleClass="detail" columnClasses="label">

			<h:outputLabel value="Categoria" for="categoriaNome" />
			<br />
			<h:selectOneListbox id="nomeCategoria" required="false" size="1"
				requiredMessage="Informe a Categoria da Noticia!"
				value="#{noticiaForm.categoriaId}">
				<f:selectItems value="#{noticiaForm.listaDeCategorias}" />
			</h:selectOneListbox>

			<h:outputLabel for="titulo" value="#{messages['noticia.title']}" />
			<h:inputText value="#{noticiaForm.noticia.titulo}" id="titulo">
				<f:validateLength maximum="100" />
			</h:inputText>
			<h:message for="titulo" styleClass="errorMessage" />

			<h:outputLabel for="description"
				value="#{messages['noticia.description']}" />
			<h:inputTextarea value="#{noticiaForm.noticia.descricao}"
				id="description" required="true" cols="50" rows="5"
				style="overflow:scroll">
				<f:validateLength maximum="255" />
			</h:inputTextarea>
			<h:message for="description" styleClass="errorMessage" />

			<h:outputLabel for="tags" value="#{messages['noticia.tags']}" />
			<h:inputText value="#{noticiaForm.noticia.tags}" id="tags"
				required="true">
				<f:validateLength maximum="100" />
			</h:inputText>
			<h:message for="tags" styleClass="errorMessage" />

			<h:outputLabel for="datainicial"
				value="#{messages['noticia.dataInicial']}" />
			<t:inputCalendar monthYearRowClass="yearMonthHeader"
				weekRowClass="weekHeader" id="dataInicial"
				currentDayCellClass="currentDayCell" popupDateFormat="dd/MM/yyyy"
				value="#{noticiaForm.noticia.dataInicial}" renderAsPopup="true"
				addResources="true" />
			<h:message for="dataInicial" styleClass="errorMessage" />

			<h:outputLabel for="dataFinal"
				value="#{messages['noticia.dataFinal']}" />
			<t:inputCalendar monthYearRowClass="yearMonthHeader"
				weekRowClass="weekHeader" id="dataFinal"
				currentDayCellClass="currentDayCell" popupDateFormat="dd/MM/yyyy"
				value="#{noticiaForm.noticia.dataFinal}" renderAsPopup="true"
				addResources="true" />
			<h:message for="dataFinal" styleClass="errorMessage" />

			<h:panelGroup>
				<h:commandButton value="Save" action="#{noticiaForm.save}" id="save"
					styleClass="button" />
				<c:if test="${not empty noticiaForm.id}">
					<h:commandButton onclick="return confirm('Confirma Exclusao?');"
						value="Delete" id="delete" action="#{noticiaForm.delete}" />
				</c:if>
				<h:commandButton value="Cancel" action="cancel" immediate="true"
					id="cancel" styleClass="button" />
			</h:panelGroup>

		</h:panelGrid>
	</h:form>

	<script type="text/javascript">
    Form.focusFirstElement(document.forms['noticiaForm']);
</script>

</f:view>
</html>